package com.bulemobi.activity.ac_guide;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import com.bulemobi.activity.ac_home_page.Ac_HomePage;
import com.bulemobi.activity.lock.pattern.CreateGesturePasswordActivity;
import com.bulemobi.activity.lock.pattern.UnlockGesturePasswordActivity;
import com.bulemobi.view.BaseActivity;
import com.jsyh.hcb.R;

/**
 * @author zengys  引导页面
 *         <p/>
 *         2014年9月18日 14:42:42
 */
public class WelcomePageActivity extends BaseActivity {
    Handler handler = new Handler() {

        public void handleMessage(Message msg) {

            switch (msg.what) {
                case 1:
                    SharedPreferences sharedPreferences = getSharedPreferences("LOCK", 0);
                    //判断是否第二次进入
                    if ("no".equals(sharedPreferences.getString("isFirst", "-1"))) {
                        if (sharedPreferences.getString("lock", "0").equals("open")) {
                            openActivity(UnlockGesturePasswordActivity.class);
                        } else if (sharedPreferences.getString("lock", "0").equals("close")) {
                            openActivity(Ac_HomePage.class);
                        }
                    } else {
//                        if (sharedPreferences.getString("lock", "0").equals("open")) {
//                            openActivity(UnlockGesturePasswordActivity.class);
//                        } else if (sharedPreferences.getString("lock", "0").equals("close")) {
//                            openActivity(Ac_HomePage.class);
//                        }
                        openActivity(CreateGesturePasswordActivity.class);
                    }
                    finish();
                    break;

                default:
                    break;
            }


        }

        ;

    };


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ac_welcome_page);
        Thread th = new Thread(new MyRunable());
        th.start();

    }

    class MyRunable implements Runnable {

        @Override
        public void run() {
            // TODO Auto-generated method stub
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            Message msg = handler.obtainMessage();
            msg.what = 1;
            handler.sendMessage(msg);
        }


    }


}
